﻿using System.Reflection;
using Mbs.ComponentModel.Container;
using Mbs.ComponentModel.Container.Fluent;
using Mbs.ComponentModel.Container.Listner;
using Mbs.Elements;
using Mbs.Globalization;
using Mbs.Messaging;
using Mbs.Windows.Elements.Builders;
using NUnit.Framework;
using Mbs.ComponentModel.Container.Loader;

namespace Mbs.Test.ElementBuilder
{
    public class TestBase
    {
        protected static readonly string[] elementKeys = { "Object", "MenuStrip", "ContextMenuStrip", "ToolStrip", "StatusStrip", "ToolStrip.Separator" ,
                "ToolStrip.MenuItem","ToolStrip.LanguageMenuItem","ToolStrip.Button","ToolStrip.ComboBox","ToolStrip.DropDown.Button","ToolStrip.Label", "ToolStrip.Split.Button","ToolStrip.Status.Label","ToolStrip.TextBox", "Smartpart"};
        private IKernel kernel;
        [SetUp]
        public void SetUp()
        {
            ResourceRepository.StringRegistry.Register("Mbs.Test.Data.Resources", Assembly.GetExecutingAssembly());

            kernel = new Kernel();

            kernel.ListnerManager.Register(InitializationListner.Instance);

            kernel.InjectStrategyManager.Register(new Mbs.ComponentModel.Container.Injection.PropertyInjectStragegy());

            kernel.LoaderManager.Register(new AssemblyLoader(kernel.GetType().Assembly));
            kernel.LoaderManager.Register(new AssemblyLoader(typeof(ToolStripBuilder).Assembly));

            //kernel.Register(f => f.Bind<IMessageBus>().To<MessageBus>());
            //kernel.Register(f => f.Bind<IElementService>().Factory((ctx) => new ElementService()));

            ////kernel.Register<IElementBuilderRepository, ElementBuilderRepository>();

            //kernel.Register<IElementBuilder, ObjectElementBuilder>("Object");
            //kernel.Register<IElementBuilder, MenuStripBuilder>("MenuStrip");
            //kernel.Register<IElementBuilder, ContextMenuStripBuilder>("ContextMenuStrip");
            //kernel.Register<IElementBuilder, ToolStripBuilder>("ToolStrip");
            //kernel.Register<IElementBuilder, StatusStripBuilder>("StatusStrip");

            //kernel.Register<IElementBuilder, ToolStripSeparatorBuilder>("ToolStrip.Separator");
            //kernel.Register<IElementBuilder, ToolStripMenuItemBuilder>("ToolStrip.MenuItem");
            //kernel.Register<IElementBuilder, LanguageMenuItemBuilder>("ToolStrip.LanguageMenuItem");
            //kernel.Register<IElementBuilder, ToolStripButtonBuilder>("ToolStrip.Button");
            //kernel.Register<IElementBuilder, ToolStripComboBoxBuilder>("ToolStrip.ComboBox");
            //kernel.Register<IElementBuilder, ToolStripDropDownButtonBuilder>("ToolStrip.DropDown.Button");

            //kernel.Register<IElementBuilder, ToolStripLabelBuilder>("ToolStrip.Label");
            //kernel.Register<IElementBuilder, ToolStripSplitButtonBuilder>("ToolStrip.Split.Button");
            //kernel.Register<IElementBuilder, ToolStripStatusLabelBuilder>("ToolStrip.Status.Label");
            //kernel.Register<IElementBuilder, ToolStripTextBoxBuilder>("ToolStrip.TextBox");

            //kernel.Register<IElementBuilder, SmartPartBuilder>("Smartpart");

            Init();
        }

        protected virtual void Init() { }
    }
}
